<?php
	function sqlConnect()
	{
		return new PDO(sqlSource, sqlUser, sqlPwd);
	}
	
	function makeFullPath($path)
	{
		if (!file_exists($path))
		{
			if (makeFullPath(dirname($path)))
			{
				return mkdir($path);
			}
		}
		else
		{
			return true;
		}
	}
	
	function init()
	{
		session_start();
		$conn = sqlConnect();
		
		//setup theme path
		$result = $conn->query("SELECT value FROM record WHERE name='theme';");
		$result->setFetchMode(PDO::FETCH_ASSOC);
		$info = $result->fetch();
		define('THEMEPATH', ABSPATH."theme/{$info['value']}/");
		define('THEMEURL', SITEURL."theme/{$info['value']}/");
		
		require_once(INCPATH.'user.class.php');
		require_once(INCPATH.'file.class.php');
	}
	
	function setup()
	{
		$time = time();
		if (isset($_SESSION['authPassed']) && $_SESSION['authPassed'] == 'True' && ($time - $_SESSION['active'] <= keepLoginTime))
		{
			define('isLogin', true);
		}
		else
		{
			$_SESSION['authPassed'] == 'False';
			define('isLogin', false);
		}
		
		$_SESSION['active'] = $time;
	}